home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_tem_meltmaze.cog < prev    next >
Text File  |  1999-11-15  |  4KB  |  184 lines

  1. # Jones 3D Cog Script
  2. #
  3. # TEM_MeltMaze.cog
  4. #
  5. # [RT] [MDR] [TRM]
  6. #
  7. # Cog to control the movement of the lava rocks in Palawan Melt Maze.
  8. #
  9. # (C) 1999 LucasArts Entertainment Company LLC. All Rights Reserved
  10. #
  11. # ========================================================================================
  12.  
  13. symbols
  14.  
  15.     message     startup
  16.     message     entered
  17.     
  18. # ************************** MISC LINKED GEOM *******************
  19.     thing        t_rock0
  20.     thing        t_rock1
  21.     thing        t_rock2
  22.     int            numRocks=3                        local
  23.     
  24.     thing       t_trigForward        linkid=1
  25.     thing       t_trigReverse        linkid=1
  26.     sector      sec_trigForward        linkid=2
  27.     sector      sec_trigReverse        linkid=2
  28.     
  29. # ************************** LINKED TIMING VARS ****************
  30.     flex        uptime=5.0
  31.     flex         delay=4.0
  32.     flex        speed=1.0
  33.     flex        startTime=1.0
  34.     
  35. # ************************** subroutines ***********************
  36.     flex        animateRocks        local
  37.  
  38. # ************************** MISC LOCAL VARS *******************
  39.     int            nCrntRock                        local
  40.     int            nNextRock                        local
  41.     int            nDirection                        local
  42.     int            idx                                local
  43.     int         dif_Level                       local
  44.  
  45. end
  46.  
  47. # ========================================================================================
  48.  
  49. code
  50.  
  51. # ........................................................................................
  52. startup:
  53.  
  54.     nDirection    = 1;
  55.     Sleep(startTime);
  56.  
  57.     call animateRocks;
  58.  
  59.     return;
  60.  
  61.  
  62. # ........................................................................................
  63. entered:
  64.  
  65.     # Remember current direction
  66.     idx = nDirection;
  67.  
  68.     # Set a direction based on triggers
  69.     if( (GetSenderRef() == t_trigForward) && (GetSenderID() == 1) )
  70.     {
  71.         Print("MM: forward direction THING trigger");
  72.         nDirection = 1;
  73.     }
  74.  
  75.     if( (GetSenderRef() == t_trigReverse) && (GetSenderID() == 1) )
  76.     {
  77.         Print("MM: reverse direction THING trigger");
  78.         nDirection = -1;
  79.     }
  80.  
  81.     if( (GetSenderRef() == sec_trigForward) && (GetSenderID() == 2) )
  82.     {
  83.         Print("MM: forward direction SECTOR trigger");
  84.         nDirection = 1;
  85.     }
  86.  
  87.     if( (GetSenderRef() == sec_trigReverse) && (GetSenderID() == 2) )
  88.     {
  89.         Print("MM: reverse direction SECTOR trigger");
  90.         nDirection = -1;
  91.     }
  92.  
  93.     # Only reset rock animation if direction actually changed
  94.     if ( nDirection != idx )
  95.     {
  96.         call animateRocks;
  97.     }
  98.         
  99.     return;
  100.  
  101.  
  102. # ========================================================================================
  103. #    Subroutines
  104. # ========================================================================================
  105. # ........................................................................................
  106. animateRocks:
  107.     # Squash any previous execution contexts
  108.     Reset();
  109.     
  110.     # Set next and current rock control vars
  111.     if ( nDirection == 1 )
  112.     {
  113.         nCrntRock    = 0;
  114.     }
  115.     else
  116.     {
  117.         nCrntRock    = numRocks - 1;
  118.     }
  119.     nNextRock    = nCrntRock + nDirection;
  120.  
  121.     # Put the rocks in their proper start pos
  122.     for (idx = 0; idx < numRocks; idx = idx + 1) 
  123.     {
  124.         if ( idx == nCrntRock )
  125.         {
  126.             MoveToFrame(t_rock0[idx], 0, speed);
  127.         }
  128.         else
  129.         {
  130.             MoveToFrame(t_rock0[idx], 1, speed);
  131.         }
  132.     }
  133.  
  134.     # Loop animate the rocks position
  135.     while (1) 
  136.     {
  137.         dif_Level = GetDifficulty();
  138.         
  139.         // Animate current and next rock in line
  140.         
  141.         if(dif_Level < 3) Sleep(uptime);            # easy
  142.         else if(dif_Level == 3) Sleep(uptime - 2);  # med
  143.         else if(dif_Level >= 4) Sleep(uptime - 3.5);  # hard
  144.         
  145.         MoveToFrame(t_rock0[nNextRock], 0, speed);
  146.         
  147.         if(dif_Level < 3) Sleep(delay);             # easy
  148.         else if(dif_Level == 3) Sleep(delay - 2);   # med
  149.         else if(dif_Level >= 4) Sleep(delay - 2.5);   # hard
  150.         
  151.         MoveToFrame(t_rock0[nCrntRock], 1, speed);
  152.  
  153.         // update rock controller values and keep them in range
  154.         nCrntRock = nCrntRock + nDirection;
  155.  
  156.         if ( nCrntRock < 0 )
  157.         {
  158.             nCrntRock = numRocks-1;
  159.         }
  160.         if ( nCrntRock >= numRocks )
  161.         {
  162.             nCrntRock = 0;
  163.         }
  164.  
  165.         nNextRock = nCrntRock + nDirection;
  166.         
  167.         if ( nNextRock < 0 )
  168.         {
  169.             nNextRock = numRocks-1;
  170.         }
  171.         if ( nNextRock >= numRocks )
  172.         {
  173.             nNextRock = 0;
  174.         }
  175.     }
  176.     
  177.     return;
  178.  
  179.  
  180. # ========================================================================================
  181.  
  182. end
  183.  
  184.